package com.hs.srm.admin.modules.pricemanagement.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hs.srm.admin.modules.pricemanagement.dao.InquiryItemDao;
import com.hs.srm.admin.modules.pricemanagement.entity.InquiryItemEntity;
import com.hs.srm.admin.modules.pricemanagement.service.InquiryItemService;
import com.hs.srm.base.common.annotation.DataFilter;
import com.hs.srm.base.common.utils.Constant;
import com.hs.srm.base.common.utils.QueryParam;
import com.hs.srm.common.utils.PageUtils;

@Service("inquiryItemService")
public class InquiryItemServiceImpl extends ServiceImpl<InquiryItemDao, InquiryItemEntity>  implements InquiryItemService {

		@Override
		@DataFilter
		public PageUtils queryPage(Map<String, Object> params) {
			// 从列表页面获取对应的值
			String purchRequestCode = (String)params.get("purchRequestCode");//采购申请单号
			

			Page<InquiryItemEntity> page = this.selectPage(
					new QueryParam<InquiryItemEntity>(params).getPage(),
					new EntityWrapper<InquiryItemEntity>()
							.like(StringUtils.isNotBlank(purchRequestCode), "purch_request_code", purchRequestCode)
							
							//.like(StringUtils.isNotBlank(vendorCodeStart), "vendor_code", vendorCodeStart)
							//.like(StringUtils.isNotBlank(vendorCodeEnd), "vendor_code", vendorCodeEnd)
							.addFilterIfNeed(!ObjectUtils.isEmpty(params.get(Constant.SQL_FILTER)),
									(String)params.get(Constant.SQL_FILTER)));
			return new PageUtils(page);
          }
        /**
         *批量查询
         */
		public List<InquiryItemEntity> selectBatchIds(List<String> ids) {
			
			return this.baseMapper.selectBatchIds(ids);
		}

	/**
	 * 通过 quotationId 找到 InquiryItemEntity
	 * @param quotationId
	 * @return
	 */
	@Override
	public InquiryItemEntity selectItemByQuotationId(String quotationId) {
		return this.baseMapper.selectItemByQuotationId(quotationId);
	}

	@Override
		public List<InquiryItemEntity> findByNo(String inquiryTotalCode) {
			// TODO Auto-generated method stub
			return this.baseMapper.findByNo(inquiryTotalCode);
		}
		@Override
		public InquiryItemEntity findByInquiryId(String inquiryId) {

			return this.baseMapper.findByInquiryId(inquiryId);
		}
		

}
